package user_service

import (
	"time"

	"bird/internal/api/repository/db_repo/driver_info_repo"
	"bird/internal/pkg/core"
)

func (s *service) RegisterDriver(ctx core.Context, userData *RegisterData) (id int32, err error) {
	driverModel := driver_info_repo.NewModel()
	driverModel.PhoneNo = userData.PhoneNo
	driverModel.VehLicenseUrl = userData.VehLicenseUrl
	driverModel.VehLicenseExpire = time.Unix(userData.VehLicenseExpire, 0)
	driverModel.DriverLicenseUrl = userData.DriverLicenseUrl
	driverModel.DriverLicenseExpire = time.Unix(userData.DriverLicenseExpire, 0)
	driverModel.InsuranceUrl = userData.InsuranceUrl
	driverModel.InnsuranceExpire = time.Unix(userData.InsuranceExpire, 0)
	driverModel.QualificationCertUrl = userData.QualificationCertUrl
	//默认未审核
	//driverModel.Status = 2

	//写入driver_info表
	id, err = driverModel.Create(s.db.GetDbW().WithContext(ctx.RequestContext()))

	return
}
